#pragma once
#include <string>
#include <arpa/inet.h>
#include <cstring>
#include <unistd.h>

class TCPSocket
{
private:
    int port;
    int sockfd;
    const std::string addr_str;
    struct sockaddr_in addr_info;

public:
    TCPSocket(const std::string &addr, const int port);

    int connect() const;

    int get_fd() const;

    ~TCPSocket();

    int write(const std::string &msg);

    std::string read(int nbytes);
};